﻿using System;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;

namespace FtpUploadWeb.Common
{
    /// <summary>
    /// 压缩文件帮助类
    /// </summary>
    public class BatHelper
    {
        public static string BatFilePath;

        public static void ExecuteBat()
        {
            try
            {
                TaskManage.WriteTextLog("ExecuteBat", "开始执行文件:" + BatFilePath );

                Process pro = new Process();
                FileInfo file = new FileInfo(BatFilePath);
                pro.StartInfo.WorkingDirectory = file.Directory.FullName;
                pro.StartInfo.FileName = BatFilePath;
                pro.StartInfo.CreateNoWindow = true;//隐藏窗体的显示
                pro.Start();
                pro.WaitForExit();

                TaskManage.WriteTextLog("ExecuteBat", "Bat文件执行完成:" + BatFilePath);
            }
            catch (Exception ex)
            {
                TaskManage.WriteTextLog("ExecuteBat", "错误:" + ex.ToString());
            }
        }

    }
}
